package com.bdan.t382;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class PrinterTest {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        Printer printer = context.getBean("printer", Printer.class);

        try {
            printer.print("Spring AOP 功能增强测试文档");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
    // public static void main(String[] args) {
    //     // 加载Spring配置文件
    //     ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    //     // 获取彩色打印机并打印测试页
    //     Printer colorPrinter = (Printer) context.getBean("colorPrinter");
    //     colorPrinter.print("彩色打印机测试页");
    //     System.out.println("------------------------");
    //     // 获取黑白打印机并打印测试页
    //     Printer grayPrinter = (Printer) context.getBean("grayPrinter");
    //     grayPrinter.print("黑白打印机测试页");
    //
    // }

}



